<%@ page contentType="text/html; charset=UTF-8" import="com.pub.database.QueryBean,java.io.*,java.util.ArrayList,java.util.Arrays"%>
<%
        QueryBean lqbnDAO=null;
        StringBuffer lstbText=new StringBuffer();
        String lstrTemp=new String();
        ArrayList altSQL=null;
        String strExecuteStatus=null;

        FileReader FileStream = null;
        BufferedReader BufferedStream = null;

        try{
            // 1. 建立文字檔讀取物件
            FileStream = new FileReader("d:\\test.sql");

            // 2. 透過 BufferedReader 幫我們讀資料
            BufferedStream = new BufferedReader(FileStream);

            //讀取資料
            do {
                // 3. 接著 一行一行 的把資料從檔案中讀出來
                lstrTemp = BufferedStream.readLine();
                if(lstrTemp !=null && !(lstrTemp.indexOf("prompt")==0 || lstrTemp.indexOf("commit")==0)){
                  lstbText.append(lstrTemp);
                }
            } while (lstrTemp != null);

            altSQL = new ArrayList(Arrays.asList(lstbText.toString().split(";")));

            //altSQL.remove(altSQL.size()-1);

            lqbnDAO = new QueryBean("SQLITE_SWD",true,"big5","big5");

            strExecuteStatus=lqbnDAO.executeSQL(altSQL);

        }
        catch(Exception e){
            e.printStackTrace();
        }
        finally{
            if(lqbnDAO!=null){
                try{lqbnDAO.close();lqbnDAO=null;}catch(Exception se){se.printStackTrace();}
            }
            if(BufferedStream!=null){
                try{BufferedStream.close();BufferedStream=null;}catch(Exception se){se.printStackTrace();}
            }
            if(FileStream!=null){
                try{FileStream.close();FileStream=null;}catch(Exception se){se.printStackTrace();}
            }
            if(altSQL!=null){
                altSQL.clear();
                altSQL=null;
            }

            lstbText=null;
        }
%>
<html>
<head>
<title>
createTableToSQLite
</title>
</head>
<body bgcolor="#ffffff">
<h1>
<%=strExecuteStatus%>
</h1>
</body>
</html>
